package com.service.admin.borrow.service.converter;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.service.admin.borrow.controller.rep.MemberBorrowPageRep;
import com.service.dao.model.MemberBorrow;
import jodd.util.ObjectUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

public class MemberBorrowConverter {
    public static MemberBorrowPageRep converter(MemberBorrow memberBorrow){
        if(ObjectUtils.isEmpty(memberBorrow)){
            return null;
        }
        MemberBorrowPageRep rep = new MemberBorrowPageRep();
        BeanUtils.copyProperties(memberBorrow,rep);
        return rep;
    }

    public static List<MemberBorrowPageRep> converter(List<MemberBorrow> list){
        if(CollectionUtils.isEmpty(list)){
            return null;
        }
        List<MemberBorrowPageRep> repList = new ArrayList<>();
        for(MemberBorrow memberBorrow: list){
            MemberBorrowPageRep rep = converter(memberBorrow);
            if(rep == null){
                continue;
            }
            repList.add(rep);
        }
        return repList;
    }

}
